package com.jaymin.flink.sink;

import org.apache.flink.api.java.tuple.Tuple3;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisCommand;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisCommandDescription;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisMapper;

/**
 * @author jaymin
 * @since 2024/4/5 23:55
 */
public class RedisExampleMapperV2 implements RedisMapper<Tuple3<String, Integer, Integer>> {


    @Override
    public RedisCommandDescription getCommandDescription() {
        return new RedisCommandDescription(RedisCommand.HSET, "os_user-cnt:20301002");
    }

    @Override
    public String getKeyFromData(Tuple3<String, Integer, Integer> stringIntegerIntegerTuple3) {
        return stringIntegerIntegerTuple3.f0 + "_" + stringIntegerIntegerTuple3.f1;
    }

    @Override
    public String getValueFromData(Tuple3<String, Integer, Integer> stringIntegerIntegerTuple3) {
        return stringIntegerIntegerTuple3.f2 + "";
    }
}
